home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4861 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  53 lines

  1. Newsgroups: comp.lang.c
  2. Path: news.csug.rochester.edu!rit!kar
  3. From: kar@cs.rit.edu (Kenneth A Reek)
  4. Subject: What's your compiler's answer?
  5. Message-ID: <1996Feb7.140945.28351@cs.rit.edu>
  6. Sender: news@cs.rit.edu (USENET News Admin)
  7. Nntp-Posting-Host: athens
  8. Organization: Rochester Institute of Technology, Rochester, NY
  9. Date: Wed, 7 Feb 1996 14:09:45 GMT
  10.  
  11.     In preparing some materials for a course, I wrote the following
  12. program to illustrate that the order of expression evaluation is not
  13. determined completely by the precedence of the operators involved.  I
  14. ran it on every compiler I could find and, not surprisingly, got lots of
  15. different answers.
  16.  
  17.     I'd like to get results from this program for as many different
  18. compilers as I can to drive home the point that expressions of this
  19. sort must be avoided.  If you have access to a C compiler OTHER THAN
  20. THE ONES LISTED BELOW, I'd be grateful if you could run this program 
  21. and send me the results.  Please include the operating system you are
  22. using (if appropriate to the identification of the compiler) and the
  23. compiler version number if it has one.
  24.  
  25.     Thanks for your help.  E-mail your results to kar@cs.rit.edu
  26. I'll post the results if anyone is interested.  
  27.  
  28.     - Ken
  29.  
  30. Here's the program (hold on to your hats):
  31.  
  32.     int main(){
  33.         int i = 10;
  34.  
  35.         i = i-- - --i * ( i = -3 ) * i++ + ++i;
  36.         printf( "i = %d\n", i );
  37.         return 0;
  38.     }
  39.  
  40. Results found to date:
  41.  
  42. 21    Borland C/C++ 4.0, Turbo C++ 4.5
  43. -86    Sun 3/50 cc
  44. -85    Sun Sparc cc, SunOS 4.1.4 (a K&R compiler)
  45. 4    Sun Sparc acc, SunOS 4.1.4 (an ANSI compiler)
  46. 36    DEC VAX/VMS
  47. 21    Silicon Graphics Indy, IRIX 5.3
  48. -63    gcc 2.6.3
  49. -- 
  50. Kenneth A. Reek                kar@cs.rit.edu
  51. Rochester Institute of Technology    716-475-6155 (voice)
  52. Rochester, NY 14623-0887 USA        716-475-7100 (fax)
  53.